# 面向对象oop编程
class Person:
    hobby = 'Play  Computer'

    def __init__(self, name, age, gender):
        # 属性前面加双下划线，为私有属性，只能通过方法修改
        self.name = name
        self._age = age
        self.__gender = gender

    def set_gender(self, gender):
        self.__gender = gender

    @property
    def get_gender(self):
        return self.__gender

    @classmethod
    def get_hobby(cls):
        return cls.hobby

    def self_introduction(self):
        return 'name:%s age:%s gender:%s' % (self.name, self._age, self.__gender)


class Play:
    pass


class Child(Person):
    def __init__(self, name, age, gender):
        super().__init__(name, age, gender)

    def self_introduction(self):
        return 'Hello, I am Child'


if __name__ == '__main__':
    person = Person('陆小虎', 20, '女')
    print(type(person))
    print('=====================================打印所有属性==============================================')
    print(dir(person))
    print('=================================打印从构造函数中获得的属性======================================')
    print(person.__dict__)
    person.age = 30
    person.set_gender('男')
    # 变相的防卫私有属性gender
    print(person._Person__gender)
    print(Person.get_hobby())
    print(person.get_gender)
    print(person.self_introduction())

    child = Child('顾小兔', 30, '男')
    print(child.self_introduction())

    print(isinstance(child, Child))